<template>
<el-container class="home-container">
  <el-aside width="200px" style="background-color: rgb(238, 241, 246)">
   <div class="logo-box">
                <img src="../imgs/bandle.png" />
                <el-div></el-div>
                <!-- <el-h6>WBG</el-h6> -->
            </div>
    <el-menu :default-active="activePath">
      <el-menu-item index="1-1"><router-link to="/welcome" @click="saveNavState('/welcome')">首页</router-link></el-menu-item>
      <el-menu-item index="1-2"><router-link to="/gm" @click="saveNavState('/gm')">商品管理</router-link></el-menu-item>
      <el-menu-item index="1-3"><router-link to="/om">订单管理</router-link></el-menu-item>
      <el-menu-item index="1-4"><router-link to="/fm">财务管理</router-link></el-menu-item>
      <el-menu-item index="1-5"><router-link to="/da">数据分析</router-link></el-menu-item>
      <el-menu-item index="1-6"><router-link to="/sys">系统设置</router-link></el-menu-item>
    </el-menu>
  </el-aside>
  <el-container>
    <el-header>
      <div> 
        <div class="r-content">
          <el-dropdown trigger="click" szie="mini">
            <span class="el-dropdown-link">
              下拉菜单<i class=" el-icon--right"></i>
            </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item>个人中心</el-dropdown-item>
              <el-dropdown-item>退出</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </div>
      </div>
    </el-header>
    <!-- 路由占位符 -->
    <el-main><router-view></router-view></el-main>
  </el-container>
</el-container>
</template>

<script>
export default {
  data() {
    return {
      // 左侧菜单数据
      menulist: [],
      // 是否折叠
      isCollapse: false,
      // 被激活的链接地址
      activePath: ''
    }
  },
  created() {
    this.getMenuList()
    this.activePath = window.sessionStorage.getItem('activePath')
  },
  methods: {
    logout() {
      window.sessionStorage.clear()
      this.$router.push('/login')
    },
    // 获取所有的菜单
    async getMenuList() {
      const { data: res } = await this.$http.get('menus')
      if (res.meta.status !== 200) return this.$message.error(res.meta.msg)
      this.menulist = res.data
      console.log(res)
    },
    // 点击按钮，切换菜单的折叠与展开
    toggleCollapse() {
      this.isCollapse = !this.isCollapse
    },
    // 保存链接的激活状态
    saveNavState(activePath) {
      window.sessionStorage.setItem('activePath', activePath)
      this.activePath = activePath
    }
  }
}
</script>

<style lang="less" scoped>
header[data-v-8dc7cce2] {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    height: 100px;
    -webkit-box-pack: justify;
    -ms-flex-pack: justify;
    justify-content: space-between;
    flex-direction: row-reverse;
}
 .el-dropdown-link {
    cursor: pointer;
    color: #409EFF;
  }
  .el-icon-arrow-down {
    font-size: 12px;
  }
.logo-box {
    text-align: center;
    height: 150px;
    padding: 0px 0px;
}
.home-container {
  height: 100%;
}
  .el-header, .el-footer {
    background-color: #B3C0D1;
    color: #333;
    text-align: center;
    line-height: 60px;
  }
  .el-aside {
    background-color: #D3DCE6;
    color: #333;
    text-align: center;
    line-height: 200px;
  }
  .el-main {
    background-color: #E9EEF3;
    color: #333;
    text-align: center;
    line-height: 160px;
  }
  body > .el-container {
    margin-bottom: 40px;
  }
  .el-container:nth-child(5) .el-aside,
  .el-container:nth-child(6) .el-aside {
    line-height: 260px;
  }
  .el-container:nth-child(7) .el-aside {
    line-height: 320px;
  }
</style>
